package com.coin.controller;

import com.coin.service.MemberService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by chenhao on 2017/5/18.
 */
@RestController
@RequestMapping("/member")
public class MemberController {
    private Logger logger= LoggerFactory.getLogger(this.getClass());

    @Resource
    private MemberService memberService;

    @GetMapping("/createMember")
    public ResponseEntity<Boolean> createMember(@RequestParam String name,
                                                @RequestParam String wxNumber,
                                                @RequestParam String zfbNumber,
                                                @RequestParam String phoneNumber){

        try {

            boolean success=memberService.addMemberInfo(name,wxNumber,zfbNumber,phoneNumber);
            return new ResponseEntity<Boolean>(success, HttpStatus.OK);
        }catch (Exception e){
            logger.error("Exception :{}",e);
            return new ResponseEntity<Boolean>( HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}
